#!/usr/bin/env python
#
# http://sluggo.scrapping.cc/python/WebHelpers/modules/feedgenerator.html

import sys
import datetime
import uuid
import webhelpers.feedgenerator as fd
#feed = feedgenerator.Rss201rev2Feed(

class record:
    def __init__(self,t,l,d,y,m,dd):
        self.title=t
        self.link=l
        self.description=d
        self.date=datetime.date(y,m,dd)

title = "Munipack"
link = "http://integral.physics.muni.cz/"

feed = fd.Atom1Feed(title,link,"Munipack Home Page",author_name="Filip Hroch")

#    language="en",
#)
#feed.add_item(title="Munipack 0.5.2", link="http://integral.physics.muni.cz", description="Astrometry release")
#feed.add_item(title="Munipack 0.5.3", link="http://integral.physics.muni.cz", description="Batch astrometry release")
#sfeed = feedgenerator.SyndicationFeed(title="t",link="sw",description="wes")
#x=sfeed.rfc2822_date("2011-01-10")
#y=sfeed.get_tag_uri("http://integral.physics.muni.cz", feedgenerator.latest_post_date())
#print sfeed.num_items()
#n=sfeed.num_items()
#print feedgenerator.rfc2822_date(datetime.date(2012,1,12))
#print feedgenerator.rfc3339_date(datetime.date(2012,1,12))
#print sfeed.latest_post_date()
#print feedgenerator.get_tag_uri("http://www.x.x",datetime.date(2011,10,19))
#print uuid.uuid3(uuid.NAMESPACE_URL,"")


records = [
    record(title+" 0.5.0",link,"Start of New Generation",2010,02,10),
    record(title+" 0.5.1",link,"Coloring release",2010,10,17),
    record(title+" 0.5.2",link,"Astrometry release",2011,10,19),
    record(title+" 0.5.3",link,"Batch astrometry release",2012,01,13)
]
   
for r in records:
   d = str(r.date)
   u = "urn:uuid:" + str(uuid.uuid3(uuid.NAMESPACE_URL,r.link + "," + d))
   feed.add_item(r.title,r.link,r.description,pubdate=r.date,unique_id=u)



#date = datetime.date(2010,02,10)
#ui = "urn:uuid:" + str(uuid.uuid3(uuid.NAMESPACE_URL,link + "," + str(date)))

#feed.add_item("Munipack 0.5.0","http://integral.physics.muni.cz/","New Generation Start",pubdate=date,unique_id=ui)
#feed.add_item("Munipack 0.5.0","http://integral.physics.muni.cz/","New Generation Start",pubdate=date,unique_id=ui)
#feed.add_item("Munipack 0.5.1","http://integral.physics.muni.cz/","Coloring release",pubdate=datetime.date(2010,10,17))
#feed.add_item("Munipack 0.5.2","http://integral.physics.muni.cz/","Astrometry release",pubdate=datetime.date(2011,10,19),unique_id="urn:uuid:"+str(uuid.uuid3(uuid.NAMESPACE_URL,"integral.physics.muni.cz,2010-02-10")))
#feed.add_item("Munipack 0.5.3","http://integral.physics.muni.cz/","Batch astrometry release",pubdate=datetime.date(2012,1,13))
#print feed.num_items()
#xfeed = feedgenerator.Rss201rev2Feed(sfeed)
#fp = open('news_feed.xml', 'w')
#fp = sys.stdout
feed.write(sys.stdout, 'utf-8')
#fp.close()
